#include "qthememodel.h"

QThemeModel::QThemeModel(const QString & projectPath, QObject *parent) :
    QFileSystemModel(parent), m_projectPath(projectPath)
{
}

bool QThemeModel::isValid()
{
    return QThemeModel::isValid(m_projectPath);
}

QModelIndex QThemeModel::setRootPath(const QString &path)
{
    if (QThemeModel::isValid(path))
        return QFileSystemModel::setRootPath(path);
    else
        return QModelIndex();
}

bool QThemeModel::isValid(const QString &projectPath)
{
    QDir kproject(projectPath);

    /*!
      The method starts by checking if the directory exists
      and if it contains all subdirectories and files which
      define a KDE theme structure.
      TODO : complete the list of files and directories to
      check their existence
     */
    return  (kproject.exists() &&
             kproject.exists("metadata.desktop") &&
             kproject.exists("colors")
             );
}
